home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / SAMPLES.BIN / AboutDialog.java < prev    next >
Encoding:
Java Source  |  1996-12-08  |  1.6 KB  |  68 lines

  1.  
  2.  
  3.  
  4. /*
  5.     A basic extension of the java.awt.Dialog class
  6.  */
  7.  
  8. import java.awt.*;
  9.  
  10. public class AboutDialog extends Dialog {
  11.     void okButton_Clicked(Event event) {
  12.         //{{CONNECTION
  13.         // Clicked from okButton Hide the Dialog
  14.         hide();
  15.         //}}
  16.     }
  17.  
  18.     public AboutDialog(Frame parent, boolean modal) {
  19.  
  20.         super(parent, modal);
  21.  
  22.         //{{INIT_CONTROLS
  23.         setLayout(null);
  24.         addNotify();
  25.         resize(insets().left + insets().right + 357,insets().top + insets().bottom + 158);
  26.         label1 = new java.awt.Label("JavaPad - A Simple editor written in Java!");
  27.         label1.reshape(insets().left + 50,insets().top + 40,251,21);
  28.         add(label1);
  29.         okButton = new java.awt.Button("OK");
  30.         okButton.reshape(insets().left + 120,insets().top + 70,95,26);
  31.         add(okButton);
  32.         setTitle("About");
  33.         setResizable(false);
  34.         //}}
  35.     }
  36.  
  37.     public AboutDialog(Frame parent, String title, boolean modal) {
  38.         this(parent, modal);
  39.         setTitle(title);
  40.     }
  41.  
  42.     public synchronized void show() {
  43.         Rectangle bounds = getParent().bounds();
  44.         Rectangle abounds = bounds();
  45.  
  46.         move(bounds.x + (bounds.width - abounds.width)/ 2,
  47.              bounds.y + (bounds.height - abounds.height)/2);
  48.  
  49.         super.show();
  50.     }
  51.  
  52.     public boolean handleEvent(Event event) {
  53.         if(event.id == Event.WINDOW_DESTROY) {
  54.             hide();
  55.             return true;
  56.         }
  57.         if (event.target == okButton && event.id == Event.ACTION_EVENT) {
  58.             okButton_Clicked(event);
  59.         }
  60.         return super.handleEvent(event);
  61.     }
  62.  
  63.     //{{DECLARE_CONTROLS
  64.     java.awt.Label label1;
  65.     java.awt.Button okButton;
  66.     //}}
  67. }
  68.